/**
 * Created by zhaoxk on 2017/2/24.
 */
import moment from 'moment';

const diifTimer = ({
    from,
    to = moment(),
    unit = 'days'
}) => {
    if (from) {
        if (typeof from === 'string') {
            from = moment(from);
        }
        return to.diff(from, unit);
    }
    throw new Error('from 参数必填，从何时开始计算时间差？');
};

export default diifTimer;
